
using UnityEngine;

namespace ABA
{
	public class Path_ExcelConfig : IPathConfig, IEditorPrefs
	{
		private static string default_excel_folder => System.IO.Path.GetFullPath(Application.dataPath + "/../../Config");
		private static string default_gen_asset_folder => $"{Application.dataPath}/MyAssets/Config";

		private static string default_gen_csharp_folder => $"{Application.dataPath}/Scripts/Game/Data/Config";

		private static string default_gen_csharp_assembly_name = "Assembly-CSharp";

		#region 设置上的字段菜单

		[SettingProperty(FieldType.Folder, "Excel 目录: ")]
		public static string ExcelFolder
		{
			get { return EditorPrefsHelper.GetString("Path_ExcelConfig_ExcelFolder", default_excel_folder); }
			set => EditorPrefsHelper.SetString("Path_ExcelConfig_ExcelFolder", value);
		}

		[SettingProperty(FieldType.Folder, "Gen Asset目录: ")]
		public static string GenAssetFolder
		{
			get
			{
				return EditorPrefsHelper.GetString("Path_ExcelConfig_GenAssetFolder", default_gen_asset_folder);
			}
			set => EditorPrefsHelper.SetString("Path_ExcelConfig_GenAssetFolder", value);
		}

		[SettingProperty(FieldType.Folder, "Gen C#目录: ")]
		public static string GenCSharpFolder
		{
			get
			{
				return EditorPrefsHelper.GetString("Path_ExcelConfig_GenCSharpFolder", default_gen_csharp_folder);
			}
			set => EditorPrefsHelper.SetString("Path_ExcelConfig_GenCSharpFolder", value);
		}

		[SettingProperty(FieldType.EditField, "Gen C#所在程序集：")]
		public static string TableSharpAssemblyName
		{
			get
			{
				return EditorPrefsHelper.GetString("Path_ExcelConfig_GenCSharpAssemblyName", default_gen_csharp_assembly_name);
			}
			set => EditorPrefsHelper.SetString("Path_ExcelConfig_GenCSharpAssemblyName", value);
		}

		[SettingMethod("", "打开导表工具")]
		public static void OpenConvertTableTool()
		{
			ConvertExcelWnd.ConvertExcelConfig();
		}
		#endregion

		#region IPathConfig,IEditorPrefs
		public const string TAG = "导表配置";

		public string GetModuleName()
		{
			return TAG;
		}

		public void ReleaseEditorPrefs()
		{
			EditorPrefsHelper.DeleteKey("Path_ExcelConfig_ExcelFolder");
			EditorPrefsHelper.DeleteKey("Path_ExcelConfig_GenAssetFolder");
			EditorPrefsHelper.DeleteKey("Path_ExcelConfig_GenCSharpFolder");
		}

		#endregion
	}
}